
package promogui;

import java.util.HashMap;
import java.util.Iterator;



public class WeeklyProjectData {

	
	int week;
	HashMap<Engineer, Float> RE;
	HashMap<Engineer, Float> AD;
	HashMap<Engineer, Float> II;
	HashMap<Engineer, Float> BT;
	HashMap<Engineer, Float> PM;
	



	
	public WeeklyProjectData(int week){
		
		this.week = week;
		
		RE	= new HashMap<Engineer, Float>();
		AD 	= new HashMap<Engineer, Float>();
		II 	= new HashMap<Engineer, Float>();
		BT 	= new HashMap<Engineer, Float>();
		PM 	= new HashMap<Engineer, Float>();
		

		
	}
	
	public void addWeeklyEngineerData(WeeklyEngineerData data)
	{
		this.RE.put(data.engineer, data.RE);
		this.AD.put(data.engineer, data.AD);
		this.II.put(data.engineer, data.II);
		this.BT.put(data.engineer, data.BT);
		this.PM.put(data.engineer, data.PM);	
	}
	
	public WeeklyEngineerData getWeeklyEngineerDataByEngineer(Engineer engineer)
	{   
		return  new WeeklyEngineerData(RE.get(engineer), AD.get(engineer), II.get(engineer),
				BT.get(engineer), PM.get(engineer), engineer);	
	}
	
	
	
	
	public float getTotalRE()
	{
		float total = 0;
		Iterator<Float> it = RE.values().iterator();
		
		while (it.hasNext())
		{
			total += it.next();
		}
		return total;
	}	
	
	
	public float getTotalAD()
	{
		
		float total = 0;
		Iterator<Float> it = AD.values().iterator();
		
		while (it.hasNext())
		{
			total += it.next();
		}
		return total;
	}	
	
	
	
	public float getTotalII() 	
	{
		float total = 0;
		Iterator<Float> it = II.values().iterator();
		
		while (it.hasNext())
		{
			total += it.next();
		}
		return total;
		
	}	

		
		
	public float getTotalBT() 	
	{
		
		float total = 0;
		Iterator<Float> it = BT.values().iterator();
		
		while (it.hasNext())
		{
			total += it.next();
		}
		return total;
	}	
	
	
	
	public float getTotalPM() 	
	{
		
		float total = 0;
		Iterator<Float> it = PM.values().iterator();
		
		while (it.hasNext())
		{
			total += it.next();
		}
		return total;
	}	      
	
   public boolean isEmpty()
   {
       return RE.size() <= 0 && AD.size() <= 0 && II.size() <= 0 && BT.size() <= 0 && PM.size() <= 0;
   }
	
	public boolean removeEngineerData(Engineer engineer)
   {
       boolean removed = false;
       
       if (RE.containsKey(engineer))
       {
           RE.remove(engineer);
           removed = true;
       }
       
       if (AD.containsKey(engineer))
       {
           AD.remove(engineer);
           removed = true;
       }
       
       if (II.containsKey(engineer))
       {
           II.remove(engineer);
           removed = true;
       }
       
       if (BT.containsKey(engineer))
       {
           BT.remove(engineer);
           removed = true;
       }
       
       if (PM.containsKey(engineer))
       {
           PM.remove(engineer);
           removed = true;
       }
       
       return removed;
   }
	
   public Engineer getFirstEngineer()
   {
       if (RE.size() > 0)
       {
           return RE.keySet().iterator().next();
       }
        
       return new Engineer("VOID");      
   }
   
	public boolean hasEngineerData(Engineer engineer)
   {
       return RE.containsKey(engineer) || 
              AD.containsKey(engineer) ||
              II.containsKey(engineer) ||
              BT.containsKey(engineer) ||
              PM.containsKey(engineer); 
   }
   
	public float getTotalHours()
	{		
		return getTotalAD()+getTotalBT()+getTotalII()+getTotalPM()+getTotalRE();
	}
	
	
}
